package de.riceman.simpleGo.players;
import java.util.Random;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.richclient.application.Application;

import de.riceman.simpleGo.events.SimpleGoLifecycleApplicationEvent;
import de.riceman.simpleGo.main.BitMatrix;
import de.riceman.simpleGo.main.Configuration;
import de.riceman.simpleGo.main.GoGame;
import de.riceman.simpleGo.main.NewGameSetup;


/**
 * This is a damn stupid AI.
 * 
 * @author Riceman
 */
public class DamnStupidAI extends AI {
	
	private static final Log logger = LogFactory.getLog(DamnStupidAI.class);

	/**
	 * Constructor for this class.
	 * 
	 * @param name this player's name
	 * @param player this engine's player
	 * @param configuration this game's configuration
	 */
	public DamnStupidAI(String name, boolean player, Configuration configuration) {
		super(name, player, configuration);
		//analyzedPositions = 0;
	}
	
	/* (non-Javadoc)
	 * @see de.riceman.simpleGo.players.AI#generateMove()
	 */
	public void generateMove() {

		BitMatrix possibilities = configuration.getRegularMoves(player);
		
		//That's it. Really stupid.
		possibilities = possibilities.getRandomBitAsBitMatrix();
		
		try {
			Thread.sleep(200);
		} catch (InterruptedException e1) {
			e1.printStackTrace();
		}
		
		Application.instance().getApplicationContext().publishEvent(
				new SimpleGoLifecycleApplicationEvent(SimpleGoLifecycleApplicationEvent.MOVE_GENERATED, possibilities));

	}

	/* (non-Javadoc)
	 * @see de.riceman.simpleGo.players.AI#getConfigurationValue()
	 */
	@Override
	public int getConfigurationValue() {
		// TODO Auto-generated method stub
		return 0;
	}
}
